import xlrd
import os
import utils.Logger as Logger

# 原获取接口参数的值（现在废弃）
# def get_case(sheetname, ApiPurpose):
#     filename = os.path.basename(__file__).split('.')[0]
#     log = Logger.Logger(filename).getlog()
#     # 获取工作路径
#     data_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#     data = xlrd.open_workbook(r"%s\data\TEST_API_CASE.xlsx" % data_path)
#     # 读取swagger表格的每一个sheet页
#     for sheet_name in data.sheet_names():
#         if sheet_name == sheetname:
#             # 获取的sheet 名称
#             table = data.sheet_by_name(sheet_name)
#             # 获取该sheet的行数
#             nrows = table.nrows
#             # 获取该sheet的列数
#             # ncols = table.ncols
#             for i in range(1, nrows):
#                 # 使用行列索引，第1列为API Purpose，注：从0开始算
#                 API_Purpose = table.row(i)[1].value
#                 if API_Purpose == ApiPurpose:
#                     log.info('API_Purpose ===%s' % API_Purpose)
#                     case = table.row_values(i)
#                     log.info('test case ========%s' % case)
#                     return case